<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="viewport" id="viewportid" content="target-densitydpi=320,width=640,maximum-scale=1.0,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />
    <link rel="stylesheet" href="http://public.weirongm.com/DaChongQing//Draw/css/index-draw.css"  type="text/css" media="screen" />
    <link rel="stylesheet" type="text/css" href="http://public.weirongm.com/DaChongQing//Draw/css/app.css"/>
    <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.js"></script>
<body>

<div class="topm">
    <ul>
        <li>
            <span>杨洋</span>获得了大盘鸡
        </li>
        <li>
            <span>霍建华</span>获得了小盘鸡
        </li>
        <li>
            <span>潘长江</span>获得了高乐高
        </li>
        <li>
            <span>赵本山</span>跟陈冠希结为了兄弟
        </li>
        <li>
            <span>小沈阳</span>成功变性
        </li>
    </ul>
</div>

<div class="main">
    <div class="turntable" id="lottery">
        <ul class="con">
            <li  class="bg-1 lottery-unit lottery-unit-0">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/1.png-v=201506198369.png">
            </li>
            <li class="bg-2 lottery-unit lottery-unit-1">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/2.png-v=201506198369.png">
            </li>
            <li class="bg-3 lottery-unit lottery-unit-2">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/3.png-v=201506198369.png">
            </li>
            <li class="bg-4 lottery-unit lottery-unit-7">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/4.png-v=201506198369.png">
            </li>
            <li class="bg-5" data-action="start">
                <div class="btnimg"></div>
                <div class="timediv hide">
                    <input type="hidden" id="user_draw_num" value="0">
                </div>
            </li>
            <li class="bg-6 lottery-unit lottery-unit-3">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/5.png-v=201506198369.png">
            </li>
            <li class="bg-7 lottery-unit lottery-unit-6">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/6.png-v=201506198369.png">
            </li>
            <li class="bg-8 lottery-unit lottery-unit-5">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/7.png-v=201506198369.png">
            </li>
            <li class="bg-9 lottery-unit lottery-unit-4">
                <img src="http://public.weirongm.com/DaChongQing//Draw/images/8.png-v=201506198369.png">
            </li>
        </ul>
    </div>
</div>
<!-- 中奖结果 -->

<div class="realThing hide">
    <Div class="bg"></Div>
    <div class="close"></div>
    <div class="textwrap">
        <div class="imgdiv padding20"><img src="http://public.weirongm.com/DaChongQing//Draw/images/realThing.png" tppabs="http://pic.cdn.focusmedia.cn/weixin/img/realThing.png" width="100%"> </div>
        <div class="formdiv padding20">
            <p>获得周黑鸭鸭脖215gX2袋</p>
            <p> 输入联系方式，即可免费领取</p>
            <div class="namediv"><input type="text"   name="name" id="name" placeholder="请输入姓名"></div>
            <div class="teldiv"><input type="tel" name="tel" id="tel" placeholder="请输入电话"> </div>
            <div class="addressdiv"><input type="text" name="address" id="address" placeholder="请输入地址"> </div>
            <div class="btndiv padding30"><input type="button" class="nextBtn" value="下次再领"> <input type="button" class="useBtn" value="确认提交"></div>
        </div>
        <!--        <p class="looklist "><a href="#"> *中奖纪录中查看此实物免费领取信息</a></p>-->
    </div>
</div>

<!---机会用完-->
<div class="noChance hide" id="noChance">
    <Div class="bg"></Div>
    <div class="close"></div>
    <div class="textwrapb">
        <h3>机会已用完<br>
            欢迎明天再来
        </h3>
        <div class="know-btn"></div>
    </div>
</div>

<script type="text/javascript">
    var lottery={
        index:0,	//当前转动到哪个位置
        count:7,	//总共有多少个位置
        timer:0,	//setTimeout的ID，用clearTimeout清除
        speed:100,	//初始转动速度
        times:0,	//转动次数
        cycle:80,	//转动基本次数：即至少需要转动多少次再进入抽奖环节
        prize:5,	//中奖位置
        init:function(id){
            if ($("#"+id).find(".lottery-unit").length>0) {
                $lottery = $("#"+id);
                $units = $lottery.find(".lottery-unit");
                this.obj = $lottery;
                this.count = $units.length;
                $lottery.find(".lottery-unit-"+this.index).addClass("active");
            };
        },
        roll:function(){
            var index = this.index;
            var count = this.count;
            var lottery = this.obj;
            $(lottery).find(".lottery-unit-"+index).removeClass("active");
            index += 1;
            if (index>count-1) {
                index = 0;
            };
            $(lottery).find(".lottery-unit-"+index).addClass("active");
            this.index=index;
            return false;
        },
        stop:function(index){
            this.prize=index;
            return false;
        }
    };

    function roll(){
        lottery.times += 1;
        lottery.roll();
        if (lottery.times > lottery.cycle+10 && lottery.prize==lottery.index) {
            clearTimeout(lottery.timer);
            lottery.prize=-1;
            lottery.times=0;
//            $('.success').html('恭喜你，获得了'+$('.active').index()+'奖');
            setTimeout("$('.realThing').show()",500);
            click=false;
        }else{
            if (lottery.times<lottery.cycle) {
                lottery.speed -= 10;
            }else if(lottery.times==lottery.cycle) {
//                var index = Math.random()*(lottery.count)|0;
                var index = lottery.prize|0;
                lottery.prize = index;
            }else{
                if (lottery.times > lottery.cycle+10 && ((lottery.prize==0 && lottery.index==7) || lottery.prize==lottery.index+1)) {
                    lottery.speed += 110;
                }else{
                    lottery.speed += 20;
                }
            }
            if (lottery.speed<40) {
                lottery.speed=40;
            };
            //console.log(lottery.times+'^^^^^^'+lottery.speed+'^^^^^^^'+lottery.prize);
            lottery.timer = setTimeout(roll,lottery.speed);
        }
        return false;
    }

    var click=false;

    window.onload=function(){
        lottery.init('lottery');
        $(".bg-5").click(function(){
            if (click) {
                return false;
            }else{
                $.post('<?php echo U("Draw/probability");?>',{},function(data){
                    lottery.speed=100;
                    lottery.prize= data;
                    roll();
                    click=true;
                    return false;
                })
            }
        });
    };
    $('.close').click(function(){
        $('.realThing').hide();
    })
</script>

</body>
</html>